package cn.echase.ecare.yinfayun.controller.finance;

import cn.echase.common.result.aop.EchaseResponseResult;
import cn.echase.ecare.yinfayun.domain.dto.OrgTransactionRecordDto;
import cn.echase.ecare.yinfayun.service.impl.OrgTransactionRecordServiceImpl;
import cn.hutool.json.JSONObject;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 机构交易记录
 */
@RestController
@EchaseResponseResult
@RequiredArgsConstructor
@RequestMapping("/orgTransactionRecord/v1")
public class OrgTransactionRecordController {

    private final OrgTransactionRecordServiceImpl baseService;

    /**
     * 获取机构交易记录分页(支付明细)
     */
    @PostMapping(value = "page")
    public JSONObject getOrgTransactionRecordPage(@RequestBody OrgTransactionRecordDto orgTransactionRecord) {
        if (StringUtils.isEmpty(orgTransactionRecord.getTenantId())) {
            orgTransactionRecord.setTenantId(LoginHelper.getOrgId());
        }
        return baseService.page(orgTransactionRecord);
    }

    /**
     * 导出机构交易记录(支付明细)
     */
    @PostMapping(value = "export")
    public void export(HttpServletResponse httpServletResponse, @RequestBody OrgTransactionRecordDto orgTransactionRecord) {
        if (StringUtils.isEmpty(orgTransactionRecord.getTenantId())) {
            orgTransactionRecord.setTenantId(LoginHelper.getOrgId());
        }
        baseService.export(httpServletResponse, orgTransactionRecord);
    }

}
